package work803.work2;

import java.util.Objects;

public class Employee {
  private int id;
  private String name;
  private int age;
  private double salary;

  public Employee() {
  }

  public Employee(int id, String name, int age, double salary) {
    this.id = id;
    this.name = name;
    this.age = age;
    this.salary = salary;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public double getSalary() {
    return salary;
  }

  public void setSalary(double salary) {
    this.salary = salary;
  }

  @Override
  public int hashCode() {
    return Objects.hash(getId(),getName());
  }

  @Override
  public boolean equals(Object obj) {
    Employee employee = (Employee)obj;
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof Employee)) {
      return false;
    }

    if (getId() == employee.getId() && getName().equals(employee.getName()) ){
           return  true;
    }else {
    return false;
  }
  }

  @Override
  public String toString() {
    return "员工号："+getId()+",员工姓名："+getName()+"，员工年龄："+getAge()+"，员工工资："+getSalary();
  }
}
